#ifndef KVS_DEFINES
#define KVS_DEFINES

typedef int	STATE;
typedef int	PTR_DISK;
typedef int	PTR_KW;
typedef int	HASH;
typedef	int	INIT_TYPE;

typedef	unsigned int	uint;
typedef	unsigned char	uchar;
typedef	uchar		block;

#define	INIT_TYPE_CREATE	0
#define	INIT_TYPE_LOAD		1
#define PTR_KW_SIZE		4
#define CHUNK_SIZE		(16*1024)
#define	KV_PAGE_SIZE		(4*1024)
#define	IDX_NODE_SIZE		24
#define	IDX_NODE_FULL		(10000001)

/**********************************************/
#define SEG_ALLOC_SUCCESS	0
#define SEG_RELEASE_SUCCESS	0
#define SEG_LOAD_SUCCESS	0
#define SEG_SAVE_SUCCESS	0

#define	HT_TABLE_MOD		131071 
#define HT_TABLE_SIZE		131072

/***********************************************/
/* K-byte-oriented    XXX: K*/
#define	IMAGE_K_BASIS_SIZE	513	
#define	IMAGE_K_IDX_NODE_SIZE	234376
#define	IMAGE_K_BUDDY_SIZE	524288
#define IMAGE_K_SIZE		759177	

#define	IMAGE_K_BASIS		0
#define IMAGE_K_IDX_NODE	(IMAGE_K_BASIS+IMAGE_K_BASIS_SIZE)	
#define IMAGE_K_BUDDY		(IMAGE_K_IDX_NODE+IMAGE_K_IDX_NODE_SIZE)

/* [IMAGE_BASIS] */
#define	IMAGE_IDX_HORIZON	0
#define IMAGE_HT_TABLE		(IMAGE_IDX_HORIZON+4)
#define	IMAGE_BUDDY_FLIST	(IMAGE_HT_TABLE+524288)
#define	IMAGE_BUDDY_FLEN	(IMAGE_BUDDY_FLIST+32*8)
#define	IMAGE_BUDDY_MAX_CNT	(IMAGE_BUDDY_FLEN+4)
#define IMAGE_SEG_INFO		(IMAGE_BUDDY_MAX_CNT+4)
/* [IMAGE BUDDY] */
	

/* CHUNK_oriented */
#define	DISK_IMAGE_SIZE		47449
#define	DISK_SEG_SIZE		2560
#define	DISK_IMAGE		0
#define	DISK_VALUE		(DISK_IMAGE + DISK_IMAGE_SIZE)







#endif

/* sth. about IMAGE: 
 
|	      			     |
|<-------------IMAGE---------------->|
|        |             |             |                          |           |
|Basis   |idx_nodes    | Buddy S.    | VALUE                    | SEG       |
|        |             |             |                          |           | 

basis data:
--ht_table
--idx_horizon
--SEG_INFO:
  [SEG_NAME]  [max_page_id]  [iterm_horizon]  [ptr_disk]
*/
